# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=openpyxl
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=2.6.4
pkgrel=1
pkgdesc="A python library to read/write Excel 2007 xlsx/xlsm file (mingw-w64)"
url="https://openpyxl.readthedocs.io/"
arch=('any')
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python2-jdcal"
         "${MINGW_PACKAGE_PREFIX}-python2-et-xmlfile"
         "${MINGW_PACKAGE_PREFIX}-python2-defusedxml"
         "${MINGW_PACKAGE_PREFIX}-python2-pandas"
         "${MINGW_PACKAGE_PREFIX}-python2-pillow")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-pip"
             "${MINGW_PACKAGE_PREFIX}-python2-pytest")
_pkgtag='983cb2595f1c'
source=(openpyxl-${pkgver}.tar.gz::"https://bitbucket.org/openpyxl/openpyxl/get/${pkgver}.tar.gz"
        "LICENSE")
sha256sums=('56d39ba957df8c470637875de3e8da8bed1643bf12b6166e41fa42d9cccab1ae'
            '717016f755510c08d8752a7d2cf0a355624d380b68b88e9d92ea153ea896daaa')

prepare() {
  rm -rf python2-build-${CARCH}
  cp -r "openpyxl-openpyxl-${_pkgtag}" python2-build-${CARCH}
}

build() {
  msg "Python 2 build for ${CARCH}"  
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 ${srcdir}/LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE
}
